/****************************************************************************
**
** PacketManager.h
**
** Copyright (C) August 2014 Hotride
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
*****************************************************************************
*/
//---------------------------------------------------------------------------
#ifndef PacketManagerH
#define PacketManagerH
//---------------------------------------------------------------------------
#define HANDLER_PACKET(name) void handle_ ##name (PBYTE buf, int size);
//---------------------------------------------------------------------------
class TPacketManager
{
private:
	static MessageType m_message_types[];

	CLIENT_VERSION m_ClientVersion;
	
protected:
	HANDLER_PACKET(server_list)
	HANDLER_PACKET(login_error)
	HANDLER_PACKET(relay_server)
	HANDLER_PACKET(character_list)
	HANDLER_PACKET(login_complete)
	HANDLER_PACKET(enter_world)
	HANDLER_PACKET(update_hitpoints)
	HANDLER_PACKET(update_mana)
	HANDLER_PACKET(update_stamina)
	HANDLER_PACKET(update_player)
	HANDLER_PACKET(character_status)
	HANDLER_PACKET(update_item)
	HANDLER_PACKET(update_object)
	HANDLER_PACKET(update_contained_item)
	HANDLER_PACKET(update_contained_items)
	HANDLER_PACKET(deny_move_item)
	HANDLER_PACKET(update_character)
	HANDLER_PACKET(warmode)
	HANDLER_PACKET(set_time)
	HANDLER_PACKET(client_pause)
	HANDLER_PACKET(open_paperdoll)
	HANDLER_PACKET(open_gump)
	HANDLER_PACKET(open_menu_gump)
	HANDLER_PACKET(open_container)
	HANDLER_PACKET(equip_item)
	HANDLER_PACKET(delete_object)
	HANDLER_PACKET(client_version)
	HANDLER_PACKET(update_skills)
	HANDLER_PACKET(new_command_filter)
	HANDLER_PACKET(deny_walk)
	HANDLER_PACKET(confirm_walk)
	HANDLER_PACKET(open_compressed_gump)
	HANDLER_PACKET(open_url)
	HANDLER_PACKET(target)
	HANDLER_PACKET(display_map)
	HANDLER_PACKET(map_data)
	HANDLER_PACKET(secure_trading)
	HANDLER_PACKET(talk)
	HANDLER_PACKET(unicode_talk)
	HANDLER_PACKET(text_entry_dialog)
	HANDLER_PACKET(ping)
	HANDLER_PACKET(set_weather)
	HANDLER_PACKET(tip_window)
	HANDLER_PACKET(object_light_level)
	HANDLER_PACKET(light_level)
	HANDLER_PACKET(buy_list)
	HANDLER_PACKET(sell_list)
	HANDLER_PACKET(vendor_buy_reply)

public:
	TPacketManager();
	~TPacketManager() {}
	
	int GetPacketSize(BYTE msg);
	void ReceiveHandler(PBYTE buf, int size);
	void SetClientVersion(CLIENT_VERSION cver);

	MessageType GetType(BYTE ID) const {return m_message_types[ID];}
};
//---------------------------------------------------------------------------
#endif